package com.icode.web.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by ZhongGang
 * at 2015/1/24
 */
@Controller
public class StoreController {
    @Autowired
    private OAuth2RestTemplate storeRestTemplate;

    @RequestMapping("/store/user/info")
    public String getUserInfoOfStore(Model model) {
        JSONObject jsonMap = storeRestTemplate.getForObject("http://localhost:8080/store/user/info.json", JSONObject.class);
        model.addAttribute("user", jsonMap);
        return "userInfo";
    }
}
